<div class="panel panel-inverse modal-dialog modal-md" data-sortable-id="ui-general-1">
    <div class="panel-heading">
        <div class="panel-heading-btn">
            <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-danger" data-dismiss="modal" ><i class="fa fa-times"></i></a>
        </div>
        <h4 class="panel-title">用户信息</h4>
    </div>
    <div class="panel-body">
        <div class="profile-section">
            <div class="profile-left">
                <div class="profile-image">
                    <img src="assets/img/default.jpg" id="userinfoAvatar"/>
                    <i class="fa fa-user hide"></i>
                </div>
                <div class="m-b-10"><a href="javascript:void(0);" onclick="changeAvatar()" class="btn btn-warning btn-block btn-sm">更换头像</a></div>
                <div class="profile-highlight">
                    <h4><i class="fa fa-cog"></i> 个人描述</h4>
                    <a href="javascript:void(0);" data-type="textarea" id="moperDesc">[[${#strings.defaultString(user.description,'个人签名')}]]</a>
                </div>
            </div>
            <!-- begin profile-right -->
            <div class="profile-right">
                <div class="profile-info">
                    <!-- begin table -->
                    <div class="table-responsive">
                        <table class="table table-profile">
                            <thead><tr><th></th><th><h4><a href="javascript:void(0)" data-type="text" id="monickname">[[${user.nickname}]]</a></h4></th></tr></thead>
                            <tbody>
                                <tr class="highlight">
                                    <td class="field">用户名</td>
                                    <td>[[${user.username}]]</td>
                                </tr>
                                <tr>
                                    <td class="field">部门</td>
                                    <td>[[${#strings.defaultString(user.deptName,'无部门信息')}]]</td>
                                </tr>
                                <tr class="highlight">
                                    <td class="field">角色</td>
                                    <td>[[${user.roleName}]]</td>
                                </tr>
                                <tr class="divider"><td colspan="2"></td></tr>
                                <tr>
                                    <td class="field">手机</td>
                                    <td><i class="fa fa-mobile fa-lg m-r-5"></i><a href="javascript:void(0);" data-type="text" id="moMobile" class="m-l-5">[[${#strings.defaultString(user.mobile,'未绑定手机号')}]]</a> </td>
                                </tr>
                                <tr>
                                    <td class="field">邮箱</td>
                                    <td><i class="fa fa-fa-tag fa-lg m-r-5"></i><a href="javascript:void(0)" data-type="text" id="moEmail">[[${#strings.defaultString(user.email,'未绑定邮箱')}]]</a></td>
                                </tr>
                                <tr>
                                    <td class="field">性别</td>
                                    <td><i  class="fa fa-male m-r-5"></i><a href="javascript:void(0)" data-type="select" id="moxin">[[${user.ssex}]]</a></td>
                                </tr>
                                <tr class="divider"><td colspan="2"></td></tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--更换用户的头像-->
<div class="modal fade" id="user_avatar" data-keyboard="false" data-backdrop="static" tabindex="-1"></div>


<script data-th-inline="javascript">
    var userinfoAvatar = [[${user.avatar}]];
    $("#userinfoAvatar").attr("src","img/avatar/"+userinfoAvatar);
    /**修改手机号**/
    $("#moMobile").editable({
        url:function (parame) {
            $.post(ctx+"user/updateUserProfile",{mobile:parame.value,userId:parame.pk},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:[[${user.userId}]],
        defaultValue:"",
        title:"手机号",
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });
    /**修改邮箱**/
    $("#moEmail").editable({
        url:function (parame) {
            $.post(ctx+"user/updateUserProfile",{email:parame.value,userId:parame.pk},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:[[${user.userId}]],
        defaultValue:"",
        title:"邮箱",
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });
    /**修改性别**/
    $("#moxin").editable({
        url:function (parame) {
            $.post(ctx+"user/updateUserProfile",{ssex:parame.value,userId:parame.pk},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:[[${user.userId}]],
        defaultValue:"",
        title:"性别",
        source: [{ value: 0, text: "男" }, { value: 1, text: "女" }, {value:2,text:"保密"}],
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });
    /**修改昵称**/
    $("#monickname").editable({
        url:function (parame) {
            $.post(ctx+"user/updateUserProfile",{nickname:parame.value,userId:parame.pk},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:[[${user.userId}]],
        defaultValue:"",
        title:"修改昵称",
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });
    /**修改个人描述**/
    $("#moperDesc").editable({
        url:function (parame) {
            $.post(ctx+"user/updateUserProfile",{description:parame.value,userId:parame.pk},function (r) {
                if (r.code === 0) {
                    $JuXue.n_success(r.msg);
                } else {
                    $JuXue.n_danger(r.msg);
                }
            });
        },
        pk:[[${user.userId}]],
        defaultValue:"",
        title:"修改个人描述",
        validate: function (value) { //字段验证
            if (!$.trim(value)) {
                return '不能为空';
            }
        }
    });
    /**更换头像***/
    function changeAvatar() {
        $.post(ctx+"user/moAvatar",{},function (r) {
            $("#user_avatar").empty().append(r).modal("show");
        });
    }
</script>
